package com.firesrc.db;

import jodd.db.oom.DbOomManager;
import jodd.db.pool.CoreConnectionPool;

import com.firesrc.bean.Config;
import com.firesrc.bean.ExceptionLog;
import com.firesrc.bean.MailContent;
import com.firesrc.bean.MailDayAmount;
import com.firesrc.bean.MailHost;
import com.firesrc.bean.MailSubject;
import com.firesrc.bean.SendRecord;

public class DBManager {
	private static CoreConnectionPool cp;

	public static synchronized CoreConnectionPool getPublicConnectionPool() {
		if (cp != null) {
			return cp;
		}
		DbOomManager dbOom = DbOomManager.getInstance();
		dbOom.registerEntity(MailHost.class, true);
		dbOom.registerEntity(SendRecord.class, true);
		dbOom.registerEntity(ExceptionLog.class, true);
		dbOom.registerEntity(MailDayAmount.class, true);
		dbOom.registerEntity(MailSubject.class, true);
		dbOom.registerEntity(Config.class, true);
		dbOom.registerEntity(MailContent.class, true);
		cp = new CoreConnectionPool();
		cp.setDriver("org.h2.Driver");
		// cp.setUrl("jdbc:h2:~/baidu");
		cp.setUrl("jdbc:h2:tcp://localhost/~/etschool");
		cp.setUser("sa");
		cp.setPassword("hkdjxl");
		cp.init();
		cp.setMaxConnections(60);
		return cp;
	}

}
